package cc.yugu.yhdw.common.domain.hdw;

import cc.yugu.yhdw.common.domain.LongIdEntity;
import cc.yugu.yhdw.common.entity.json.DateTimeSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 厂商出入流水帐
 */
public class SupplierInOutMoney extends LongIdEntity {

    public enum BizType {
        CHARGE_INCOME(1, "换电收入"),
        CHARGE_REFUND(2, "换电退款");
        ;

        private final int value;
        private final String name;

        private BizType(int value, String name) {
            this.value = value;
            this.name = name;
        }

        private static Map<Integer, String> map = new HashMap<Integer, String>();

        static {
            for (BizType e : BizType.values()) {
                map.put(e.getValue(), e.getName());
            }
        }

        public static String getName(int value) {
            return map.get(value);
        }

        public int getValue() {
            return value;
        }

        public String getName() {
            return name;
        }
    }

    Integer supplierId;
    Integer money; //分
    Integer bizType;//业务类型
    String sourceId;
    Date createTime;

    public SupplierInOutMoney() {
    }

    public SupplierInOutMoney(Integer supplierId, Integer money, Integer bizType, String sourceId, Date createTime) {
        this.supplierId = supplierId;
        this.money = money;
        this.bizType = bizType;
        this.sourceId = sourceId;
        this.createTime = createTime;
    }

    public Integer getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Integer supplierId) {
        this.supplierId = supplierId;
    }

    public Integer getBizType() {
        return bizType;
    }

    public void setBizType(Integer bizType) {
        this.bizType = bizType;
    }

    public String getSourceId() {
        return sourceId;
    }

    public void setSourceId(String sourceId) {
        this.sourceId = sourceId;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getBizTypeName() {
        if (bizType != null) {
            return BizType.getName(bizType);
        }
        return "";
    }
}
